package com.lyz.myself.controller.login;

import com.github.pagehelper.PageInfo;
import com.lyz.myself.config.utils.Result;
import com.lyz.myself.pojo.Po.User;
import com.lyz.myself.service.UserService;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private UserService userService;

    @ApiOperation("所有用户,admin权限")
    @RequestMapping(value = "/getAll", method = RequestMethod.POST)
    //@RequiresPermissions(logical = Logical.AND, value = {"admin"})
//    @RequiresRoles(value={"admin","user"},logical = Logical.OR)
    @RequiresRoles(value={"admin"},logical = Logical.OR)
    public Result getAll(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum, @RequestParam(value = "pageNum",defaultValue = "10")Integer pageSize) {
        PageInfo<User> pageInfo = userService.getAll(pageNum, pageSize);
        return Result.success(pageInfo,"查询成功！");
    }

}
